﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Shared/ContentMaster.master"
    CodeFile="userList.aspx.cs" Inherits="ltMan_users_userList" %>

<%@ Register Src="LockCommandEx.ascx" TagName="LockCommandEx" TagPrefix="uc1" %>
<asp:Content ID="C1" ContentPlaceHolderID="head" runat="Server">
    <style>
        .pageview-container {
            border: 1px solid #898c95;
            margin-top: -1px;
        }
        .pageview {
            padding: 10px;
        }
        .info-container {
            padding: 30px;
        }
        .info-container label {
            width: 60px;
            display: inline-block;
        }
    </style>
</asp:Content>
<asp:Content ID="C2" ContentPlaceHolderID="CPH1" runat="Server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script>
            var win1;
            function reloadData() {
                if (win1)
                    win1.close();
                $find('<%=RadGrid1.ClientID %>').get_masterTableView().rebind();
            }
            function PopUpShowing(sender, eventArgs) {
                var popUp = eventArgs.get_popUp();
                var gridWidth = sender.get_element().offsetWidth;
                var popUpWidth = parseInt(popUp.style.width);
                popUp.style.left = ((gridWidth - popUpWidth) / 2 + sender.get_element().offsetLeft).toString() + "px";
            } 
            Sys.Application.add_load(function () {
                $('.grid-inline-key').click(function () {
                    win1 = radopen('userPermission.aspx?id=' + $(this).attr('eid'));
                    win1.setSize(400, 390);
                    win1.set_title('设置权限');
                });
            });
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManagerProxy runat="server" ID="proxy1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="b1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    <div class="searchArea">
        用户名：<telerik:RadTextBox EmptyMessage="搜索用户名" ID="sName" runat="server" MaxLength="20" />
        <telerik:RadButton Icon-PrimaryIconCssClass="icon-search" runat="server" ID="b1"
            OnClick="b1_Click" Text="搜索" />
    </div>
    <telerik:RadGrid ID="RadGrid1" runat="server" Width="100%" OnDeleteCommand="RadGrid1_DeleteCommand"
        OnItemCommand="RadGrid1_ItemCommand" PageSize="12" OnItemCreated="RadGrid1_ItemCreated"
        OnInsertCommand="RadGrid1_InsertCommand" OnUpdateCommand="RadGrid1_UpdateCommand"
        OnItemDataBound="RadGrid1_ItemDataBound">
        <ClientSettings><ClientEvents OnPopUpShowing="PopUpShowing" />
            <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="340" />
        </ClientSettings>
        <MasterTableView CommandItemDisplay="Top" EditMode="PopUp" DataKeyNames="user_id">
            <CommandItemTemplate>
                <telerikEx:GridCommandEx ID="GridCommandEx1" runat="server" /><span class="pad3blk">
                <uc1:LockCommandEx ID="LockCommandEx1" runat="server" /></span>
            </CommandItemTemplate>
            <PagerTemplate>
                <telerikEx:RadPagerEx ID="RadPagerEx1" runat="server" />
            </PagerTemplate>
            <Columns>
                <telerik:GridClientSelectColumn HeaderStyle-Width="28" ItemStyle-Width="28" />
                <telerik:GridBoundColumn DataField="user_id" Visible="false" />
                <telerik:GridBoundColumn HeaderText="用户名" DataField="username" DataFormatString="<nobr>{0}</nobr>" />
                <%--<telerik:GridTemplateColumn HeaderStyle-Width="40" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="性别">
                    <ItemTemplate>
                        <%# Convert.ToBoolean(Eval("sex"))?"女":"男" %>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>--%>
                <telerik:GridBoundColumn HeaderStyle-Width="120" HeaderText="邮箱" DataField="email"
                    DataFormatString="<nobr>{0}</nobr>" />
                <telerik:GridBoundColumn HeaderStyle-Width="80" HeaderText="QQ" DataField="oicq"
                    DataFormatString="<nobr>{0}</nobr>" />
                <telerik:GridBoundColumn HeaderStyle-Width="55" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="发布数" DataField="fb_num" />
                <telerik:GridBoundColumn HeaderStyle-Width="55" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="审核数" DataField="sh_num" />
                <telerik:GridBoundColumn HeaderStyle-Width="80" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="注册时间" DataField="regdate" DataFormatString="{0:yyyy-MM-dd}" />
                <telerik:GridTemplateColumn HeaderStyle-Width="40" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="状态" SortExpression="lock">
                    <ItemTemplate>
                        <%# Convert.ToInt32(Eval("lock"))==1?"锁定":"正常" %>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderStyle-Width="40" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="权限">
                    <ItemTemplate>
                        <asp:LinkButton ID="lKey" CssClass="icon icon-key grid-inline-key" runat="server" ToolTip="权限" eid='<%# Eval("user_id") %>' Visible='<%#Eval("username")!=CurrentUser.username&&Convert.ToInt32(Eval("is_man"))!=0 %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderStyle-Width="50" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="操作">
                    <ItemTemplate>
                        <telerikEx:GridInlineCommandEx ID="GridInlineCommandEx1" runat="server" ShowDelete='<%#Eval("username")!=CurrentUser.username&&Convert.ToInt32(Eval("is_man"))!=0 %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
            <EditFormSettings EditFormType="Template" CaptionFormatString="当前修改[{0}]" CaptionDataField="username"
                InsertCaption="添加用户">
                <PopUpSettings Modal="true" Width="350" Height="370" />
                <FormTemplate>
                    <div class="info-container">
                        <telerik:RadTabStrip ID="RadPanelBar1" runat="server" MultiPageID="mp1" CausesValidation="false">
                            <Tabs>
                                <telerik:RadTab Text="基本信息" Selected="true" />
                                <telerik:RadTab Text="其他信息" />
                            </Tabs>
                        </telerik:RadTabStrip>
                        <telerik:RadMultiPage runat="server" ID="mp1" CssClass="pageview-container">
                            <telerik:RadPageView ID="RadPageView1" runat="server" Selected="true" CssClass="pageview">
                                <div>
                                    <br />
                                    <asp:HiddenField ID="HiddenField11" runat="server" Value='<%#Bind("user_id") %>' />
                                    <telerik:RadTextBox MaxLength="30" Label="用户名：" ID="RadTextBox1" runat="server" Text='<%# Bind("username" ) %>'
                                        ToolTip="输入用户名" EmptyMessage="输入用户名" Width="180" /><asp:RequiredFieldValidator runat="server"
                                            ID="r1" ControlToValidate="RadTextBox1" Display="Dynamic" ErrorMessage="<br/>用户名必填" />
                                </div>
                                <div>
                                    <br />
                                    <telerik:RadTextBox MaxLength="20" TextMode="Password" Label="用户密码：" ID="RadTextBox2"
                                        runat="server" Text='<%# Bind("userpass" ) %>' ToolTip="输入用户密码" Width="180" />
                                    <asp:RequiredFieldValidator runat="server" ID="r2" ControlToValidate="RadTextBox2"
                                        ErrorMessage="<br/>密码必填" Display="Dynamic" Enabled='<%# Container.DataItem is Telerik.Web.UI.GridInsertionObject %>' />
                                </div>
                                <div>
                                    <br />
                                    <telerik:RadTextBox MaxLength="20" TextMode="Password" Label="重复密码：" ID="RadTextBox3"
                                        runat="server" ToolTip="输入重复密码" Width="180" />
                                    <asp:CompareValidator runat="server" ID="c1" ControlToValidate="RadTextBox2" ControlToCompare="RadTextBox3"
                                        ErrorMessage="<br/>两次密码不一致" Display="Dynamic" />
                                </div>
                                <div>
                                    <br />
                                    <telerik:RadTextBox MaxLength="20" Label="姓名：" ID="RadTextBox4" runat="server" Text='<%# Bind("truename" ) %>'
                                        ToolTip="输入姓名" EmptyMessage="输入姓名" Width="180" />
                                </div>
                                <div>
                                    <br />
                                    <label>
                                        性别：</label>
                                    <asp:HiddenField ID="HiddenField2" runat="server" Value='<%# Bind("sex") %>' />
                                    <telerik:RadButton ID="cSex" runat="server" ToggleType="CustomToggle" UseSubmitBehavior="false"
                                        AutoPostBack="false" CausesValidation="false">
                                        <ToggleStates>
                                            <telerik:RadButtonToggleState PrimaryIconUrl="~/shared/img/assert/user.png" Text="男" />
                                            <telerik:RadButtonToggleState PrimaryIconUrl="~/shared/img/assert/user_female.png"
                                                Text="女" />
                                        </ToggleStates>
                                    </telerik:RadButton>
                                </div>
                            </telerik:RadPageView>
                            <telerik:RadPageView ID="RadPageView2" runat="server" CssClass="pageview">
                                <div>
                                    <br />
                                    <telerik:RadTextBox MaxLength="15" Label="OICQ：" ID="RadTextBox5" runat="server"
                                        Text='<%# Bind("oicq" ) %>' ToolTip="输入OICQ" EmptyMessage="输入OICQ" Width="180" />
                                </div>
                                <div>
                                    <br />
                                    <telerik:RadTextBox MaxLength="50" Label="电子邮箱：" ID="RadTextBox6" runat="server"
                                        Text='<%# Bind("email" ) %>' ToolTip="输入电子邮箱" EmptyMessage="输入电子邮箱" Width="180" />
                                </div>
                                <div>
                                    <br />
                                    <telerik:RadTextBox MaxLength="50" Label="主页地址：" ID="RadTextBox7" runat="server"
                                        Text='<%# Bind("homepage" ) %>' ToolTip="输入主页地址" EmptyMessage="输入主页地址" Width="180" />
                                </div>
                                <div>
                                    <br />
                                    <telerik:RadTextBox MaxLength="100" Label="简要说明：" ID="RadTextBox8" runat="server"
                                        Text='<%# Bind("jm" ) %>' ToolTip="输入简要说明" EmptyMessage="输入简要说明" Width="180" />
                                </div>
                            </telerik:RadPageView>
                        </telerik:RadMultiPage>
                        <div class="ta-center">
                            <br />
                            <telerik:RadButton ID="btnUpdate" Text="更新" runat="server" CommandName="Update" Visible='<%# !(Container.DataItem is Telerik.Web.UI.GridInsertionObject) %>'
                                Icon-PrimaryIconCssClass="icon-edit" />
                            <telerik:RadButton ID="btnInsert" Text="插入" runat="server" CommandName="PerformInsert"
                                Visible='<%# Container.DataItem is Telerik.Web.UI.GridInsertionObject %>' Icon-PrimaryIconCssClass="icon-add" />
                            <telerik:RadButton ID="btnCancel" Text="取消" runat="server" CausesValidation="False"
                                CommandName="Cancel" Icon-PrimaryIconCssClass="icon-cancel" />
                        </div>
                    </div>
                </FormTemplate>
            </EditFormSettings>
        </MasterTableView>
    </telerik:RadGrid>
</asp:Content>
